Perhaps this is a good use case for a ring buffer?