Bug fix for Issue #7 and some optimization

Still crazily inefficient: path.mininax example use 2.6GB memory.