Refactor deployment functions further