clean up and merge to middleman