Fix memory leak due to the use of perl_clone. A mutex is used