perlcritic, perltidy comments added, fix bug in subs folding