Added preduce and did related improvements