Clean up _getFileExtension() method and fix all its callers