Improved login and registration functionality