Adding licence; fixing minor bugs