Fixed a potential NameError, revised imports.