Fixed $format setting (flipped "html" and "plain").  Simplified tag stripping.
More code cleanup and regexp optimizations.
Numerous optimizations and code cleanup.
Merge branch 'dev' into test