Added error code handling and manual allocation on concurrency