Added functions to classes and basic main loop