Refactored, added notes, pulled magic numbers to globals

Check out the diff.  Everything looks pretty good, but I added some refactoring to make it easier to pull out the hard-coded magic numbers.