port in some fixes from 1.6.x