Start of the refactoring of the front-end plus some backend fixes