Added javadoc and license to .java files

Added javadoc and license to .java files. 
Also removed trailing whitespaces