More refactorings and cleaning up. Almost there