Fix database connection not being closed. Fixes #142
Fix strict mode violations on full refresh. Fixes #146
Fixed login for lower API versions. Fixes #147
Removed unused code.