refactor.pl modularized in smaller pieces