refactor into managers and some other fixes

also run PHP CS fixer