Fixed a stack overflow bug.