Connected/disconnected events, and minor tweaks