Fix up async code (untested) and clean up old code too.