add support for gate repacking. closes #46