Bug fix: add checking of null.