Added documentation; first round of cleanup.