For new multisig, we want to consolidate legacy-only logic from
shared logic.
The following are only needed for legacy multisig:
- CleanupScriptCode
- legacy signature checking loop
- NULLDUMMY check
While we're at it, we clean up the rather confusing parts of the logic
involving the `i` variable, and put all stack size checks at the start.