Added timeout event listener and configurable threshold