Changed CTE to CTEData, fixed some bugs

Also forgot what else...