cleanup, and sort tasks when grabbing them