Vastly improved get_variables functions