Complete main loop

Still crashes on failure