fixed dirtree level and optimized some code