More fixes for Mongoid compatibility