Update gte3.py

Lots of minor enhancements to make it more reliable.