added role query analysis to ExternalAtoms.cpp (old version is stored in ExternalAtoms_orginal.cpp)