fixed login/logout problemes, enhanced error handling