minor refactorings to make the code look like Scala code