Implemented persistent authentication session and cleaned up for readability.