Reformatted some of the code in client to be cleaner