Fixed NPE when new log/leaf is added