fix circular buffer handling - change return values