Try adding this code at the bottom where the other smarty variables are defined:
PHP Code:
if (empty($userinfo)) {
$smarty->assign('address_fields', $address_fields);
}
e.g. after this after this one:
PHP Code:
$smarty->assign('is_areas', $is_areas);