Fix RPC problems, and add update metadata on close