Improved algorithm a ton.  Moved to directive.