Fix handling of optional import