First part of the history refactor