in reply to module problems

The reason that you see this "persistence" is because your call to Fact is my $x=Fact($f) while the loop variable is $xx. $f is not a loop variant.