Rearranging, added new filetype detection.