Lots of code cleanup - removed a lot of duplicate, boilerplate code.
More code cleanup and simplification.
Merge remote-tracking branch 'origin/master'