reverting (more or less) back to the code on trunk to see if the changes made here are the problem