Complete rewrite of deployment plan calculation.