Ugh, starting to regret writting this shit in Perl...