Cleaned up client code into classes.