common wrapper implementation moved to wrap.py