Magnetic properties and microstructure of magnesium-doped Nd-Fe-B magnets