Heavy refactoring finished