Fix more bugs in datamapper.
Improvements based on import test.