Cleaning up history generator code