minor optimizations in the script engine to save a little memory.
added (passing) tests for using $0 in the replacement template when no capturing parenthese are used in the regexes.