Reordered includes to fix 'header already sent issue' on a few pages

Updated include order to remove some warnings and improved debug text.