Fixed call stack overflow bug.
Minor changes.