Fixing some issues and adding a logout handle