Fix routing and add some logging
Refactoring and fixes again