add size calculation stuff for msg_gen