much minor refactoring.