Fix and improve pull script