Complete re-factoring of PyAVM