Merge a tested version of moriyoshi's change to support RPC and CTL plugins.