More comments/documentation and minor code cleanup.