Tidied up interrupt handling a bit.