REFACTOR: Major refactoring, breaking most spaghetti code into classes