Factor out common code, make library load async.