added license header and more code comments