Refactor SlideShow code; ensure successful wraparound on last element