Limit use of global lock in RPCs.

...and more cleanups.