Refactored readHeader and more comments