combine and simplified matching functions
replace loops with comprehensions
optimization: do not use namedtuple
some optimizations
everything relies on suffix array; allow external computation