Some stuff from Blub to deal with command timeout.