Refactor a few ugly aspects of the multiple API worker patch to make
way for multiple rpc workers. This came up as I was trying to add
multiple RPC workers using similar patterns and remembering that some
things were left in a rather awkward state.
Change-Id: I549db67af4af6a2df80e12cf233109dda5213c47