Code cleanup: shared_ptr obj creation and range-base for loops