Memory errors fixed