Refactor client's login/register stuff