Generify script a bit more and improve extention detection