minor clean up and perf tweak, and reconcile code and paper