More scalafication work. I'll finish it tomorrow