Moved the history code to a separate module