XXX add is_a_tty wrapper
XXX add mdata-delete, fix mdata-put, etc