More refactoring, basic data writing restored