Copy messages array to prevent concurrent modification exception