Added nil class checks