Added some comments and cleaned up some code. No change in functionality from previous commit.