Optimization

Specialize the IRQ handler into two separate functions to reduce checks.