Overhaul of algorithm.hpp

* Better types, more flexibility for inject() and more variants of map().