Expose main algorithm at package level

This way it can be re-used from other packages.