Fixed non-deletion of queries with phase PENDING.