Added Licence info, some code cleaning.