Some rewrite and partly structured code