Compliance with rfc6749.  Added backward compatibility with Facebook custom implementation.  Simpler and faster flow.
removed need for globals