Adapted to Scala 2.11