added license and copyright stuffs and externalized lua code