Complete rewrite of JSON-RPC