update mongoid to HEAD, and fix related bugs