changes example config to new config format
refactors whole internals to use events instead of middleware
partial rewrite