add license and comments. do some cleaning.