Remove dangling code and handle token expiration edge case