nearly complete rewite in anticipation for que 0.6