Fixed the issue where tmp_vars was being set incorrect for nested subroutines