TS-2612 Fix building out of source tree, and a few other build errors