Misc fixes

Some changes I made while trying (unsuccessfully) to fix or at least diagnose a bug with a hanging SSH connection.