Add support for safe imports. Fixes #104.
Add tests for #104.