Keep middleware sorted in alphabetical order
Add missing undef references