Restructure variable handling