Detect and remove unused prefixes