Finish general refactoring