Fix HasReference
Clean up