Raven db 1140

A re-work of RavenDB-1140