Modified engine authentication flow/delegate callbacks.
Refactored authentication code.
Merge API code
Fixed merge errors