Adds preference for memory checking
Improve memory checking calculation
bug fixes.