Added rough draft of working middleware resolution