Removed unused code, expanded several comments, and removed several magic numbers.