Optimise length/2

Also change name of make_vars/2 to make_var_list/2.