Refactoring: move common code towards utils files plus variable renaming