Fix errors from ported Scala