Fix compile error
Use more idomatic scala in a few parts