Fixes #460

Ensure that variables are declared with var
(cherry picked from commit 0545b9c807b8d0285fa358225b8fb6a6096010ba)