This gets rid of cryptic bits of code with lots of bit manipulation, and makes some comments redundant.