refactored sameOpsApp
also properly group domain defs on op symbols
for #1343 all variables need to be considered to avoid clashes