Refactoring and error handling

I added error handling for critical places in jsonRPCClient class with the initial refactoring.