support inserting a middleware route & other fixes