More work on fixing reference issues.