Error and location fixes

Here's a few patches for error-reporting, and location-headers