better cross-reference handling and error reporting