Fixed DB handling, RSA key handling, and SHA1-secured login
Merged with Noel's updates