auto reconnect, buffering, some comments added