rearracnge classes (and unify Java and Scala API)