I think this might be a lot more readable if we used [splitext](http://docs.python.org/2/library/os.path.html#os.path.splitext)