Better base name detection