Added some more error handling.
Provide both Sync and Async API