Fixing memory save bug