The idea of porting this to Scala is looking nicer and nicer.