Fixed memory errors with the payload allocation