fixing controllers privilages, code refactoring, adding some debug info