More comments. Added helper function to detect end of header