Add support for safe imports. Fixes #104.

Please review. This is my first extension and while the tests pass I might still have missed to add/change something.