cleaned up the code a bit, removed extranneous comments, etc. to make it easier to read/follow