Imporved login and register api.