Refactoring controllers and directives.