Improving the reliability of NAND Flash, phase-change RAM and spin-torque transfer RAM