1. Added better null-handling (A FrameworkElement can be null in certain situations)