Cleaning up, moving modular code into separate files.