Minor change for Python 3 compatibility
Fix order of imports
Better handling of file urls