Smarter setText, plus some typescript definition fixes