Fixed variable clobbering.
Updated version.