Clean up code a bit, and provide a useful error when regex is invalid
Add support for multiline and dotall regex flags
Fix infinite loop bug
Add imatchfile line magic
Improve documentation