Improving error handling and login stuff