Fixed login, refresh and empty category seg fault bugs