Remove unused imports
Change `Warning` name
Ensure environment instance in API functions