Economy changes in China during the Tang and Song eras

How did the growing economy change China during the Tang and Song eras? How did this lead to advances in science and technology? Why do you think these changes led to a greater demand for slaves and concubines?