added license, cleaned code