Moved logout magic out of main.js