More scala magic to compactify code.