Two bugs squashed, one to go. But this is a huge one, and the code is pretty messy. ?