Exception handling and cache compiled regexp