Fixed yet another bug, it's too late to test again: needs testing.