Refactoring some subs into GeneralTools 2