We need a database connection before calling pw_header()

Also consolidate all the require calls at the top of the file