Fixed login issues and add debug messages