made a few variables local (trying to fix #53)