small changes, comments, added license for algorithm