fixed a few bugs in refactor
Merge branch 'ledger_refactor' into testing