cleaned up payload flags and header handling