Add .gitignore file, reorganize code in main.lua