Replaced "__" with "tmp_" in var names as suggested by gicmo