Committed fixes and refactoring.