Minor refactoring.
Major refactoring.