Remove hack and actually detect filetype.