Further (possibly final) bugfixes to the history system + some minor code cleanup.
Added disableUI to StateHandler.