Better route/middleware management and better CSP middleware.

See the individual commit logs for more information.