some error checking, removing tasks from stages properly