Fixed bugs with timeout