Perl-ish cleanups and fixes