Among the magnetic shape memory Heusler alloys, Ni-Mn-Ga near stoichiometry displays the largest shape change in the martensitic 5M or 7M structure with a strain of the order of 10% in an external magnetic field of less than one Tesla. In addition, the alloys exhibit a sequence of intermediate martensites with the modulated structures usually appearing at c/a < 1 while the low-temperature nonmodulated tetragonal structures have c/a > 1. Typically, the martensitic phase changes are accompanied by a shift of a peak in the electronic density arising from the non-bonding Ni states, a reconstruction of the associated Fermi surface, and, in some cases, by pronounced phonon anomalies. These appear in the cubic high-temperature austenitic and premartensitic phases but also in the modulated phases. In addition, the modulated phases have highly mobile twins which can be rearranged under the action of an external magnetic field due to the high magnetic anisotropy, which builds up in martensite and which is at the origin of the magnetic shape memory effect. First-principles calculations confirm the overall scenario.