Electronic and structural properties of MgH2.