Quits editing mode when app goes into foreground
quit editing when nothing left to edit
Fixes bug with presenting main controller during editing mode
Adds some logout logic