Scala port of Cubist runtime