minor point, but my preferred style is NULL != blah, rather than blah != NULL for conditionals