Fixed several bugs, finalized the RPC dispatcher.