[SPARK-2024] Minor refactoring