added some debugging comments; fixed a bug in the circular buffer so