found some bugs in yesterdays implementation. also did comments and improvements to code