Fix bugs and add .gitignore