code cleanup, make convert_uri more general, shorter case expressions in process_master_msg