Fix for NPE. Geoff please confirm if this is OK?