Refactor deploy

This includes the changes from PR #63