Improved login handling

Implemented storage of accounts using JSON, and improved some handling
when logging in, including trying to login when already logged in