Add .gitignore and refactor