XNAT-3347, XNAT-3280 Changes made to XDAT.
XNAT-3328 Refactored scoping functions, made event handling by scope and event work properly. Sample configurations can be found at https://gist.github.com/rherrick/0721d611a4e82326e420 and https://gist.github.com/rherrick/b1d2a6b9a23345294293.