Fix problems with null objects