update history.py

fixes vishr/local-history#27
fixes vishr/local-history#39
fixes vishr/local-history#40