Avoid const_cast and static buffer