Fix error handling, remove exception throwing

Throwing exceptions in asynchronous function is very bad because you can't catch them anywhere. At the moment most of the code changes look redundant, but this is just the first step