Split out middleware, added cookies.