Added some documentation and optimizations for client