Rewrite for GCD and more functional style.
Add .gitignore.