Changed memory to a circular buffer