Simplify RPC code with macros