some optimisations to the new mangling system