Reduce scope of RPC locks and general cleanup (RIPD-458)