Added constants, some documentation, and code cleanup.