Complete code rewrite, not using a class anymore, using templates for polymorphism.
Adapted to PajeAlign changes.