Re-added backtracking and memoization.

Gives better results for things like

    **foo*