reduced the code into a single file, added license info.