Another Batch Port from Java to Scala