Refactored the whole deploy API.