Serialize null and undefined properly