Memory related issues fix