Cleaned up the client code a bit