Direct copy from tools-2.6.11