added optional history storage in documents - this is a temporary move, I need metadata
I'll start using metadata and see about moving synctags in there
Tidied up that database a little bit, need to move transactions out of it though