Removed warning import, stray im=None, and moved os import to top