Fix for NPE caused by addObject (line 707); etc