fixed filtering of atoms: now unions are flattened before processing.