Fix credential fixing
Refactor deploy to allow reuse of helper functions