SPARK-2632, SPARK-2576. Fixed by only importing what is necessary during class definition.