Enhanced the filetype detection code.