Added file type detection after buffer load