added applyEndPatternLast feature (no tests yet), added extendedContext feature