Remove some loose ends of the old implementation

especially the portions of the code dealing with the number of
template arguments to be kept.
Performance optimisation using llvm containers.