rewrite core algorithm in more Racketish way; add caching; add #:min-ends-length keyword argument