Fixed small bug - adding reference to mdata, plus small bug iput - returning errors.