Reorganized irq and timer code