Clean up of instance selection code