Clean up the main file by moving all the routing and functions to subfiles