Initial code refactoring.