Internal code refactoring