rewrite RPC system, continue tests and debugging