Correctly reset head and tail