Optimizing the Correction of Memory Errors