reorganize sign/verify code some more