some reworking of FAT code