Reorganized middleware functionality