fix a number of minor typos / logic errors in initial refactor for model inference - now works, at least in basic test cases, though plenty of cleanup still needed