Fixes #1191. Imports in functions