Understanding the influence of Mg doping for the stabilization of capacity and higher discharge voltage of Li- and Mn-rich cathodes for Li-ion batteries.