Some changes to optionally avoid serialization when using LocalSpark.