Beginning work on tidying up the architecture of the main file