Some code cleanup.
Merge pull request #884 from cmfcmf/patch-4

Some code cleanup and fixing a minor error.