Clean up ti.py, prepare for more functionality.