Lots of configuration refactoring.
Cleaned up a little.
Added some comments