Fixed memory heap problem