Refactord codebase to not be something written at 3AM