common: Encase whole script in anonymous function

No reason not to
Create mwConfig variable as reference point for accessing config values

Individually caching popularly used values is messy not very maintainable
General cleanup