Better handling of references in resources.
Test fixes.