factor max message size
better alloc idiom
be more explicit about what's a string
factor out the safepath
remove unneeded variable
temp variable for a bit of clarity