Reorganize and upgrade middleman