Fix memory corruption bug.