cleaned up & rewrote directives generator