Fix some problems in import_data
pep8
Merge with updates