updates for middleware registration

@fosdev we will need to merge crichton develop into crichton-demo for this to work.
I want to fix "semantic bug" found today and merge this into crichton develop first. So, fix will go to crichton-demo as well.