Fixed a few bugs in payload creation