Login/security tweaks

Attempt at fixing various login/security related issues.

I've never done Objective-C so this might be terrible and/or wrong.