Fix showing StackOverflowException in some cases