Fixing compile errors for merge

Includes were missing for std::accumulate and std::any_of, furthermore
unsupported iterators cbegin() and cend() were used. Initialization of a
boost::shared_ptr to null in function parameter did not work when
actually passing 0.