Fixed issue with freeing memory.