Merged with Jona's repo
Scala-style functional