Fix mongo document bugs