Cleaned up the code and added commenting and documentation.  Final commit Winter 2014.