Looks like it works now. Dunno what was the problem. The game froze (music continued) and got out of memory error after a while.
Thanks for having another go. It's a bugger because there will be edge cases because its referencing a massive dictionary and I'm going to need some time to really thoroughly debug it. Sounds like a stack overflow, hmmm.
What did you think btw?