first draft/work in progress of inference section and minor code changes