Move some code to a better location
Fix off by one error in variable argument comparisons