Use ValuePipe for Scalar2

Fixes a bug with HashCogroup and removes code duplication.

closes #622