Refactored heavily and cleaned up code.  Verified functionality.