Butchered code to fix memory leaks and weird framework issues around navigation