Use os.path.dirname where applicable

I'm a dummy