periodic_nielsen_paths() rewritten and much faster, need to be tested, bug fixed in illegal_turns()