Further work on refactoring RPC