Reformat code, change tag read mechanism, add encoding detection, reformat tag information output.