Fixes some NPE's.