Make data conversions more robust for mongodb().  Closes #47.