More restructuring of import functions.

- Move logging to main.
- Move handling of file to its own function.
- Error handling and return values of import functions improved.