Improved handling of access tokens

in accounts.js