Reliability fixes. Minor changes, bug fixes.

I increased the reliability of several routines, and fixed a bug where
writing to the comms log would cause some gaps in the HTTP data
received.