Fix a minor bug in cyclic_pattern, remove looping when pattern reaches max size