Headers already sent bug fix