Should fix #2.
Change var names to better indicate their type and avoid confusion.