Finished most of the refactoring (except for the Gui menus, which are my next project)