Refactoring complete, now bugfixing