More refactoring etc