Modeling and managing noise in quantum error correction