Additional documentation and minor refactoring.