mtag/mtag_data: re-use the same code to store data and retrieve it