Adds DEBUG facility, Fixes bug on logout/login process when running from CGI