speed improvements for check_case_integrity script