Performance improvements for regular expressions