Better python root finding function

Idea is to prevent leaking EPC buffers.