Fix bug in previous commit.
Some code clean-up.