Finally broken up code into separate files