Flatten terms2