fix circular buffer logic ans webapp sending code.