Re-factor & fix deploy script