Fixed a re-entrancy bug.