Added configure gadgets to detect Papi, and fixed build problems