Fix for possible NPE's on trait removal