First version after refactoring.