Refactored Serial interrupt handler.