improve unsafe string hack to not rely on slice and string memory formats matching