JSON-RPC stuff and better locking.