Login done

plus LoginState session facility and fixes to stuff