History now insert only. Fixes #15 and by side effect fixes #31

Whole lock system upgraded.
Indexes had to be created to avoid deadlocks.