Added comments, improved whitespace and braces, and changed one constant
which changed in the paper since I first wrote this code.