Fixed event-loop-breaking bug