A lot more refactoring