you could use something like:
! the waters
for $1 in id ( segid = "CCCC" and name o1 ) loop main
b = ( (not hydrogen) and byres id $1)
end loop main
for the waters and similarly for other hetero entities
--gerard