Mas refactor
Controller/ajax refactor.