Fixed some things that I overlooked and which made the code not compilable. Made syntax more Scala.