Fixed many bugs in client and Endpoints code