Move loop handling to visitors.