Improve line number information.

Fixes #5825