Cleanup

Added comments, cleaned up code, and added additional test case