adding buffer stuff, and catching undefined ledger condition

These changes (including the input/buffer lines) were necessary to get this node app to run.