First 1.7 commit

Nearly ported to 1.7