Reviewed the algos module.

Made it leaner and more metaprogramming friendly.