Fixed possible NPE after the tail collection is cleared.