Fix critical bug.

Must take care when mutating hash refs.