Reorganised the code into a module with the ability to save/load data