Improve error messages and function header parsing.