Update script, fixing bugs