Functional tests and refactoring.
Merge Conflict