Fixed refactored refs

Signed-off-by: Simon Bailey <simon@newtriks.com>
Refactored directive logic

Signed-off-by: Simon Bailey <simon@newtriks.com>