factor out generation of block calls and defs