Port of ESMS to Scala