Fine tuning Apache Spark program with less stages