Use the non-scan version by default, since it's faster.
Add inplace optimizations.