Big refactor to handle scoped configuration

Fixes #86
Merge branch 'scoped-configuration'

* scoped-configuration:
  Big refactor to handle scoped configuration