I see that this block of code was mostly copied from collectDirectives().  It can be simplified...