Add .gitignore.
Add class-based implementation for thread-safety.