energy function works.  things compile.  MinSeam function is super ugly and not tested