More refactoring

**not ready for merge**