Modified max-flow to use less pointers