collection refactored to arr; flags moved to cfs; various refactored