Fixed heap corruption bug.