Simplified login code
Merge and clean up of debug code