Once the basic functionality has been sorted out, we should split the code into smaller modules and add some tests.