Fixes to wallet code factorization