Extract history management in its own module