lots of minor clean-up (and irq handler bug fix)