More flexible implementation of theory_directives.