Json change

Hi Stepan,

Thanks for your email this morning, I'm responding to that separately. In the meantime, here is a small pull request. The only functional change is to the JSON protocol, so that a function with no parameters may be called with no request body, previously an empty JSON object, "{}", had to be passed or json.loads would throw an exception when passed an empty string.

There are also just a few cleanups, which are not functional changes, but as I have gotten familiar with the code, I thought they might make the logic clearer. Hope it is helpful.

Thanks,Spencer