Fixes for the Scala implementation