Added diagnostics middleware