Copied over functionality from multi-row branch.

Couldn’t merge the branch so just copied the changes.