Updated Javascript and logout scripts
Implemented token expiry check (untested)