Some fixes

wondering if it makes sense to put this regexp in a variable out of the function; I don't know if the JS engine optimize this