Fix NPE warning; use locale for toLowerCase

Fix a minor thing I noticed while reviewing a PR.