Code Refactor in memory management module.