fixed bugs on defragmentation