async fixes, add isFirst/Last/middle, formatting

Copy scope to avoid errors in async evaluation specifically in cases of
looping. Wrap errors. Formatting.