Cleaning up some of the scala code