better rpc error handling
add rpc Define/Undefine mechanism