Improved performance of prep_deploy

Takes 1 minute and 30 seconds now instead of 3.5minutes.