Another big refactoring, still not compiling...