Reorganizing middleware