Contribution by Janos Haber for the Scala binding