Moved authentication code back into main, refactored to use classes instead of dicts

Preparation for eventual move to database.