Improved directory scan algorithm

every directory is only scan once
Merge branch 'master' of https://github.com/yeyan/xtag