Some refactoring and documentation cleanup.