Minor refactoring of scala utils.