Changed some internal design and added much scaladocs