Minor RPC cleanups

Some code movement and minor improvements, to prepare for HTTP REST support (#2844).

Even if HTTP REST is delayed or does not go in, these cleanups remain useful.