Rework frontend - separate functions now for iterating per frame
and for doing teardown - Emscripten and Apple ports can make use
of this now so we don't need separate frontend implementations