clean up collect_*

There were some dependencies between collect_sqrt and collect_const that
were reduced. collect_sqrt is more specialized in terms of collection
so it does the preprocessing with content_primitive; this is no longer
done at the lower-level collect_const routine. Also, collect_const
processes items in an ordered manner, so collect_sqrt no longer needs
the sorting of vars before the call to collect_const.