Mongoid4 compatibility

I'm running this agains mongoid4 on the master branch.