Code cleanup
Avoid double-free for each task when deallocating