Refactor some uses of empty() to be compatible with older versions of PHP