Lmdb backend

Redone lmdb pull request with rebased merges (apart from the different pull requests that have been merged in to this)