Fix checking history, and various bug fixes along the way