Adds support for additional columns in selects

This is a rebased version of #5548