Still refactoring the matching code. The goal is to preserve functionality while making it more readable.