Improved auto-detect variables and warnings