Add some null checks, might fix the NPE's