Fixed issue with double flush of response causing IllegalStateException. Added error detection for token expiration.