Improve reference resolve