Completed TWI functions, untested