Divided History states and actual History management, refactored all occurrences of history-related functions to use the new version.