Refactoring a bit and starting on the Perl backend