Fix latent bug involving undefined variable

This should never be hit, but I put logic in to catch it just in case
Add .gitignore