Fixed bugs and logging

2 log files are used now: One for general logging (at this time only
failed login attempts are logged, they can be used e.g. for fail2ban)
and one for debug messages such as exceptions.
Also fixed bugs that would prevent the app from working with the apache
web server.