Some refactoring and RPC related checks (#12598).

Change-Id: I34722695d1735db97e786412b0f2651971f87336