Two error handling fixes

Hi, two small fixes for you. The last one fixes reconnecting if the connection is interrupted, which previously resulted in a NullPointerException.