Several refactors with logout and profile template implementation.