Scala version

This is a rewrite of the project in scala.
The first rewrite uses code that is very "java-like" scala: the next step is to do some refactoring in order to use more appropriate scala predicates where is possibile.