use os.path.normpath before os.path.dirname, so we're sure what we're getting