Put http request aside, change from synch to asynch connection, tidy up login code