Set up stream timeouts as early as possible

The patch by Jonathan Oliver.
Strip some trailing ws
merge bug26334 into default