Abstracted , etc.; now fully working except for .
Updated for changed order of arguments to  and .
Modified to work with AD version 4.*