Refactored everything exept directives