Simplified loop implementation.
I gave up on wrapping shared_ptr, and just used it directly.

Signed-off-by: Peter Atashian <retep998@gmail.com>