finished TeaModel join, and some database optimizatisns