Better source tree scanning code