Fully migrated code from original ViridianSpark implementation.