Converted some Java code to Scala.
Converted some Java code to Scala