Changed some logic from authentication library (for my personal use). Updated some code from the admin logic files.