Code cleanup and general improvements
Less Globals. Minor Improvements.