Made null checking function easier to read by splitting it, and simplified the public functions' use of it.