Fix version generation and reindent code