[SPARK-4409] Third pass of code review