Smarter file extension logic.