Refactor prefixes to patterns.