Fixed a pretty serious bug in Labyrinth's matching algorithm