Also, removed line wraps in toText function and added validation of the flags field when calling unpack.