Re #1471 Fixing issues causing null pointer exceptions.