fix reconnect problem + minor improvements