backport avr32 fixes from trunk