updated directives, and fixed some scoping issues