Memory related fixes.