Consolidated and cleaned up file type detection