Fixing some threading issues with RPC.