Mod: final version of code.