Updates to packages and refactor of Owin middleware