Regex fixes

This is addressing both #2 and #3.