Fix Ref-Counting Error in Versions

Fixes #136 - now stores the current version a local variable when references several
times in a function to avoid race conditions.