Partial fixes for https://issues.cask.co/browse/CDAP-703 and https://issues.cask.co/browse/CDAP-460. Remainder of work will have to wait until 2.7.0.