Add comments and logging to tundra.tn:derive