Cleaned up client code, commented, tested extensively