Improved referenced rows handling