Support mongoid4

This has a lot of duplication between mongoid 3 and 4 that should be removed before merging. Let me know if you are interested and I'll refactor.