added option argument for counting potentially shared internal objects