[SPARK-4409] Second pass of code review