Fixed per-custom result and per-custom sql template boilerplate. refs #513