fix bug with clearing IRQs. Issue #37