Fixed parsing header and globals

This is why you don't just copy-paste functions from testing to production, kids.