Moved tree rebuilding procedure to the end of the import task