Ported from ViridianSpark library. This version doesn't build, because we're missing dependencies.