Some improvements to the script, notably introducing deploy & undeploy functions for readability.