Introduce ViewerRef and fix a bug on selection release