Code cleanup + minor fixes
Merge pull request #4267 from dmwm/MinorFixes

Code cleanup + minor fixes