Implement reduce operations

closes #38