Auto re-login and slightly improved exception handling