Bugfix history template, and now prevent closing unsaved note