More refactoring, start of documentation