added code and some documentation
added license info