Script to detect badly formatted cases and rebuild them