Data structure and regex refactoring.