WARNING: SEGFAULT. KeyMatch is working but causing a segfault, refactoring sort to attempt to track down the problem