Improved import, added new db features, major refactoring