db import fixes and optimizations