Improved record insertions

Dramatically improved record insertion speed by merging (nearly) all
commands into a single execution call. Still quite ugly though...