simplify export of indexes
add escapePattern method
cleanup