Final touches to history, some refactoring