fix picking required version if it's available, clean up in tweak.py module

fix for #1062 reported by @ sylmarien
fixed