More documentation; refactoring.