Refactor to get stuff out of the RPC object