some cleanup in gen_thumb code