Fix bug where chainwork would occasionally fail