Tidying up file detection