fixed an issues where references couldn't be passed into more than one nesting level of procedures/functions