Mostly refactoring