Reworked main control into Perl, added master log file