Added some scaladoc and caching.