Implement error/limit headers, improve type specs