Major improvements to API algorithm. Still unfortunately not ready for use.