Check flags instead of checking if mem is non-zero.