Code refactoring

Separating out filters and directives.