fixed possible StackOverflowException in Dispose(bool)