Improve error messages, remove dead code.