add outsourced directives to single files and clean up code