Added some comments and cleaned some things up a bit.