Port bbf9e25586b07c7e87b98218b8bd62cb5eefd33c without ApplicationMaster.Scala & SparkBuild.scala changes