ENH refactor checking of size of w.