Added dot product flattening.