Create separate controllers: one for the API and another one for the User Interface. Fix minor bugs