Added login functionality, and som eminor changes/fixes.