Licence headers added, makefile added, substr fix.