SPARK-1729. Use foreach instead of map for all Options.