Refactored the parser and added diagnostic output for file encodings.