fork from ytoolshed and fixes for modern perl compat