Fix several bugs on mongo mapping