Added max_follow argument, got rid of some unneeded repetitions