Refactoring, more Scala style.