Clean up references properly