Study of bad block management and wear leveling in nand flash memories