Merge pull request #1020 from olee/1710_branch

Code cleanup and more - he insisted
Commit missing file - fix PR 1020
Changed missing file from PR 1020