Merge in changes in #752 (SPARK-1814)