Big code refactoring