Changed memory storage to a circular buffer