changed notation and handling to be more problem-agnostic. has bugs but solves very simple tests. testcoise added.