Heavy refactoring
Cleanup