fix bugs, add rudimentary CLI