Added basic looping functionality.