Fix #597: StackOverflowException possible