compute turn penalties in lua profiles
Minor code refactoring