Added NULL handling to pack and unpack utilities.