code cleanup, added license headers