you should not feed gizmo after midnight and you should not call taxonomy_term_save() with one of the $term->parent values being equal to $term->tid. this will cause what looks like a memory heap problem and httpd process terminating (fairly recent xampp (with php5.3) on windows 7).
suggestion: have a handler for the case when a $term->parent value is the same as the $term->tid value, including something like drupal_set_message('hey there, the taxonomy term graph cannot have looped edges').
aside: can someone please explain why inside of the else on line 615 of taxonomy.module, for an update $op, the taxonomy_term_data record is *deleted*? sure, a new record is inserted, but why not have a database operation that does what the $op ingenuously purports to do? if not for that, what about for the sake of the transaction? as far as i can tell, there's no transaction to roll back if for some reason that delete operation works but the insert fails... leaving the database with an integrity issue.
another aside: discovered this issue when investigating an issue with NAT (Node Auto Term) http://drupal.org/node/1515484#comment-5828924. nat-7.x-1.x-dev (master pull up to commit 5f745634d623e97e7bc6c0023fbb3551745ff8c0), nat.module::_nat_get_term_hierarchies() returns a term reference value as a parent tid of the term being referenced. the term reference value can be the same as the NAT tid value.