Refactored some algorithms into common access