Update main.lib

offloaded most functions and variables to separate files