Merge "Avoid IllegalStateException by calling next before remove" into main