Update handling of version number.

The old one was horribly broken, also added git info.
Update .gitignore.