Fixed a couple of bugs and added the Licence