Now properly fixing element types using the algorithm from the ATB paper.