Fix memory and handle leaks
Avoid segfault when yr_re_finalize is called before yr_re_initialize