Improve import system

Catch more errors
Code refactoring