Fixed bug in reference resolution