ported all recent fixes from 1.3