Done with main program. Start refactoring