Free variables calculation, better quantify function.
Fix #181 - implement capture avoiding type substitution properly