Non-volatile resistive switching memory (ReRAM) technology promises to overcome the scaling limit approached by the conventional electron storage memories. Among a variety of ReRAM systems, the HfO2-based technology is especially attractive due to its fab-friendly fabrication process, high endurance and retention, and sub-nanosecond switching-speed. This presentation focuses on critical material structural features determining optimum operation conditions and memory cell performance, which is controlled by the inherently stochastic processes. The developed atomic-level model directly links the structural changes accompanying switching processes to stoichiometry and morphology of the cell dielectric. This enables engineering cell properties tailored to specific applications.