Added null checks to "fix" pesky NPEs