Fix bugs in implementing gem sync with mongoid